//
//  PreViewTableViewCell.m
//  UEAssistant
//
//  Created by mac on 2017/2/7.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#import "PreViewTableViewCell.h"

@interface PreViewTableViewCell ()<UITextViewDelegate>{
    
    CGSize   *_size;
}

@property (nonatomic, strong) UILabel            *numberLabel;
@property (nonatomic, strong) UILabel            *juziLabel;
@property (nonatomic, strong) UIView             *baseView;
@property (nonatomic, strong) UIView             *levelLine;
@property (nonatomic, strong) UIView             *verticalLine;
@property (nonatomic, strong) UIView             *spreline;

@end

@implementation PreViewTableViewCell

+ (instancetype)cellWithTableview:(UITableView *)tableview{
    
    static NSString *identifier = @"previewCell";
    PreViewTableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[PreViewTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    
    self.backgroundColor = RGB(250, 250, 250, 1);
    
    _numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50,35)];
    _numberLabel.backgroundColor = [UIColor clearColor];
    _numberLabel.textColor = RGB(191, 191, 191, 1);
    _numberLabel.textAlignment = NSTextAlignmentCenter;
    _numberLabel.font = [UIFont systemFontOfSize:13];
    _numberLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_numberLabel];
    
    _verticalLine = [[UIView alloc]initWithFrame:CGRectMake(_numberLabel.frame.size.width, 0, 1,50)];
    _verticalLine.backgroundColor = RGB(238, 238, 238, 1);
    [self addSubview:_verticalLine];
    
    _spreline = [[UIView alloc]initWithFrame:CGRectMake(0, 50-1, Screen_Width, 1)];
    _spreline.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
    [self addSubview:_spreline];
    
    _baseView = [[UIView alloc]initWithFrame:CGRectMake(_verticalLine.frame.origin.x+1, 0, Screen_Width-51, 50)];
    _baseView.backgroundColor = [UIColor whiteColor];
    [self addSubview:_baseView];
    
    _juziLabel = [[UILabel alloc]initWithFrame:CGRectMake(_verticalLine.frame.origin.x+1, 5, Screen_Width-51, 50)];
    _juziLabel.backgroundColor = [UIColor whiteColor];
    _juziLabel.textColor = RGB(88, 88, 88, 1);
    _juziLabel.font = [UIFont systemFontOfSize:15];
    _juziLabel.textAlignment = NSTextAlignmentLeft;
    _juziLabel.numberOfLines = 0;
    [self addSubview:_juziLabel];
    
}

- (void)setModel:(PreViewModel *)model{
    
    _model = model;
    _model.cellHeight = [YhxUtility autoSizeToThatWidth:Screen_Width-51 fontsize:15 content:_model.absolute_source]+10;
    _numberLabel.center = CGPointMake(50/2,_model.cellHeight/2);
    _baseView.frame = CGRectMake(_verticalLine.frame.origin.x+1, 0, Screen_Width-51, _model.cellHeight-1);
    _verticalLine.frame = CGRectMake(_numberLabel.frame.size.width, 0, 1,_model.cellHeight);
    _spreline.frame = CGRectMake(0, _model.cellHeight-1, Screen_Width, 0.7);
    _juziLabel.frame = CGRectMake(_verticalLine.frame.origin.x+1, 5, Screen_Width-51, _model.cellHeight-10);
    _numberLabel.text = [NSString stringWithFormat:@"%@",_model.display_rownum];
    _juziLabel.text = _model.absolute_source;
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end

